function array2dat64(datfile, img, nr,nc);


%         img_q = quantize(q, img);
%         %convert to column vector (row-major)
%         img_1d = reshape(img_q', 2, nr*nc/2)';
%         % convert to hex
%         img_1d_hex = [num2hex(q, img_1d(:,1)), num2hex(q, img_1d(:,2))];
% 
%         % Write into the file
%         fid = fopen(datfile, 'w');
%         for i=1:size(img_1d_hex,1)
%             fprintf(fid,'%16s\n', img_1d_hex(i,:));
%         end
%         fclose(fid);
%     
q24 = quantizer('fixed', [24,20]);
q32 = quantizer('fixed', [32,20]);

       img_q = quantize(q24, img);
        %convert to column vector (row-major)
        img_1d = reshape(img_q', 2, nr*nc/2)';
        % convert to hex
        img_1d_hex = [num2hex(q32, img_1d(:,1)), num2hex(q32, img_1d(:,2))];

        % Write into the file
        fid = fopen(datfile, 'w');
        for i=1:size(img_1d_hex,1)
            fprintf(fid,'%16s\n', img_1d_hex(i,:));
        end
        fclose(fid);
    